/*
 * @Description:
 * @version:
 * @Author: 尹鹏孝
 * @Date: 2023-03-15 15:06:49
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2023-03-15 16:12:50
 */
'use static'
const {Sequelize,Model}=require('sequelize')
const {
    dbName,
    host,
    user,
    password,
    port
} = require('./config').database;
const sequelize = new Sequelize(dbName,user,password,{
    dialect:'mysql',
    host,
    port,
    timezone:"+08:00",
    logging: true,
    define:{
        timestamps:true,
        paranoid: false,

    },
    pool: {
            max: 5, // 连接池的最大连接数量
            min: 0, // 连接池的最小连接数量
            idle: 10000 // 如果一个线程10秒钟内没有被使用，那么就释放线程
    }
})
sequelize.authenticate().then(() => {
    console.log("数据库连接成功");
}).catch((err) => {
    console.error("数据库连接错误：" + err);
});
module.exports = {
    sequelize
}